<template>
  <div class="learnIndex"  >
    <div class="top">
      <p>{{data.title}}</p>
      <p>考试总人数{{data.total_num}}人</p>
      <div class="btn" @click="show1()">考场筛选</div>
    </div>
    <Loading  v-if="notMore"  class="empty-text-wrap" />
      <div class="content1">
        <div class="box" v-for="(item,index) in listData" :key="index">
          <div class="left">
            <span class="no" v-if="item.top != 1 && item.top != 2 && item.top != 3 ">{{item.top}}</span>
            <div class="img">
              <img v-if="item.top == 1 " class="top1" src="@as/img/kaoshi_huangguan1@2x.png" alt>
              <img v-if="item.top == 2 " class="top1" src="@as/img/kaoshi_huangguan2@2x.png" alt>
              <img v-if="item.top == 3  " class="top1" src="@as/img/kaoshi_huangguan3@2x.png" alt>
              <img class="photo" :src="item.photo" alt>
              <img
                      v-if="item.top == 1 ||item.top == 2 || item.top == 3 "
                      class="badge"
                      src="@as/img/kaoshi_caidai@2x.png"
                      alt
              >
              <div
                      class="badge"
                      v-if="item.top == 1 ||item.top == 2 || item.top == 3 "
              >No.{{item.top}}</div>
            </div>

            <div>
              <p>{{item.name}}</p>
              <p>{{item.time_consuming | conversionToMinuteC}}</p>
            </div>
          </div>

          <div class="right">
            <span>{{item.fraction}}</span>
            <span>分</span>
          </div>
        </div>
        <!--<div class="box"></div>-->
        <!--<div class="box"></div>-->
      </div>
    <div class="box2"  >
      <div class="left">
        <span class="no" v-if="data.my_top != 1 && data.my_top != 2 && data.my_top != 3 ">{{data.my_top}}</span>
        <div class="img">
          <img
                  v-if="data.my_top == 1 ||data.my_top == 2 || data.my_top == 3 "
                  class="top1"
                  src="@as/img/kaoshi_huangguan1@2x.png"
                  alt
          >
          <img class="photo" :src="data.my_photo" alt>
          <img
                  v-if="data.my_top == 1 ||data.my_top == 2 || data.my_top == 3 "
                  class="badge"
                  src="@as/img/kaoshi_caidai@2x.png"
                  alt
          >
          <div
                  class="badge"
                  v-if="data.my_top == 1 ||data.my_top == 2 || data.my_top == 3 "
          >No.{{data.my_top}}</div>
        </div>

        <div>
          <p>{{data.my_name}}</p>
          <p>{{data.my_time_consuming | conversionToMinuteC}}</p>
        </div>
      </div>

      <div class="right">
        <span>{{data.my_fraction}}</span>
        <span>分</span>
      </div>
    </div>


       <!--<div class="box2" v-for="item of list" :key="item.id">-->
        <!--<div class="left">-->
          <!--<span class="no" v-if="item.top != 1 && item.top != 2 && item.top != 3 ">{{item.top}}</span>-->
          <!--<div class="img">-->
            <!--<img-->
              <!--v-if="item.top == 1 ||item.top == 2 || item.top == 3 "-->
              <!--class="top1"-->
              <!--src="@as/img/kaoshi_huangguan1@2x.png"-->
              <!--alt-->
            <!--&gt;-->
            <!--<img class="photo" :src="item.photo" alt>-->
            <!--<img-->
              <!--v-if="item.top == 1 ||item.top == 2 || item.top == 3 "-->
              <!--class="badge"-->
              <!--src="@as/img/kaoshi_caidai@2x.png"-->
              <!--alt-->
            <!--&gt;-->
            <!--<div-->
              <!--class="badge"-->
              <!--v-if="item.top == 1 ||item.top == 2 || item.top == 3 "-->
            <!--&gt;No.{{item.top}}</div>-->
          <!--</div>-->

          <!--<div>-->
            <!--<p>{{item.name}}</p>-->
            <!--<p>{{item.time_consuming | conversionToMinuteC}}</p>-->
          <!--</div>-->
        <!--</div>-->

        <!--<div class="right">-->
          <!--<span>{{item.fraction}}</span>-->
          <!--<span>分</span>-->
        <!--</div>-->
      <!--</div>-->

    <div class="select" v-if="show">
      <div class="shad" @click="show =false"></div>
      <div class="con">
        <div class="con1">
          <p @click="showItem(item)" v-for="item of list" :key="item.id">
            {{item.title}}
            <i
              :class="item.id ==select?'red':'lay'"
              class="iconfont iconxuexi_pinglun_gongbu"
            ></i>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
    import Loading from '@/components/emptyText.vue';
export default {
   components:{
        Loading
    },
  data() {
    return {
      listData: [],
      state:false,
      last: [],
      data: {},
      show: false,
      list: [],
      notMore:false,
        mineData:{},
      select: this.$route.query.id
    };
  },
  mounted() {
    this.init();

  },
  filters: {},
  methods: {
    init() {
      this.$http
        .get("/applets/TestInfo/rank_list", {
          id: this.select,
          phone: JSON.parse(Cookies.get('user_71ydj')).phone,
          org_id: JSON.parse(Cookies.get('user_71ydj')).organization_id
        })
        .then(res => {
          this.data = res.data;
          this.listData = res.data.rank_list;
          console.log(this.listData)
            if(this.listData.length){
                this.list = JSON.parse(JSON.stringify(this.listData));
                this.list = [this.list.pop()];
            }else{
              this.notMore =true
            }
          this.$progress.done();
        });
    },

    show1() {
      this.show = true;
      this.$http
        .get("/applets/TestInfo/exam_scene_list", {
          org_id: JSON.parse(Cookies.get('user_71ydj')).organization_id,
          phone: JSON.parse(Cookies.get('user_71ydj')).phone
        })
        .then(res => {

          this.list = res.data;
        });
    },

    showItem(item) {
      this.show = false;
      this.select = item.id;
      this.init();
    },

    answer() {
      this.$router.push({ path: "/learn/answer", query: {} });
    }
  }
};
</script>

<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
}
.red {
  color: #eb4d44;
  font-size: 18px;
}
.lay {
  font-size: 18px;
}
.select {
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  .con {
    width: 250px;
    height: 281px;
    background: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -140px;
    margin-left: -125px;
    border-radius: 4px;
    padding: 20px 26px 20px 26px;
    overflow-y: scroll;
    .con1 {
      font-size: 16px;
      color: #666;
      overflow-y: scroll;

      p {
        margin-bottom: 15px;
        display: flex;
        justify-content: space-between;
      }
    }
  }
  .shad {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    position: absolute;
    top: 0;
  }
}

.photo {
  margin: 0 !important;
  width: 40px;
  height: 40px;
  margin-left: 25px;
  border-radius: 50%;
}
.top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 90%;
  p {
    color: #ffffff;
    font-size: 15px;
    margin-top: 60px;
  }
  p + p {
    font-size: 12px;
    margin-top: 5px;
  }
}

.learnIndex {
  position: fixed;
  background: url("~@as/img/kaoshi_paihangbang@2x.png");
  background-size: 100% auto;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  flex-direction: column;
  overflow: hidden;
}

.content1 {
  z-index: 1;
  border-radius: 8px;
  /*height: 500px;*/
  width: 90%;
  margin-top: 12px;
  overflow: hidden;
  overflow-y: scroll;
  display: flex;
  flex-direction: column;
  .box {
    margin-left:5px;
    flex:1;
    margin-top: 10px;
    background: #fff;
    width: 95%;
    padding: 14px 0;
    /*min-height: 47px;*/
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      margin-left: 21px;
      display: flex;
      align-items: center;

      div {
        margin-left: 15px;
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        p {
          font-size: 14px;
          color: #000;
        }
        p + p {
          font-size: 12px;
          color: #999;
        }
      }
    }
    .no {
      font-size: 16px;
      color: #666;
    }
    .img {
      width: 40px;
      height: 40px;
      margin-left: 25px;
      border-radius: 50%;
      position: relative;
      .top1 {
        position: absolute;
        width: 23px;
        height: 22px;
        top: -12px;
        right: -10px;
      }
      .badge {
        width: 60px;
        height: auto;
        position: absolute;
        bottom: 0;
        left: 50%;
        margin-left: -30px;
        margin-bottom: -7px;
        font-size: 10px;
        text-align: center;
      }
    }

    .right {
      margin-right: 21px;
      span {
        font-size: 20px;
        color: #eb4d44;
      }
      span + span {
        margin-left: 3px;
        font-size: 14px;
      }
    }
  }


}
  .box2 {
    z-index:999;
    position: fixed;
    bottom: 0;
    margin-top: 20px;
    background: #fff;
    width: 100%;
    height: 67px;
    box-shadow: 0px -3px 15px 0px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      margin-left: 21px;
      display: flex;
      align-items: center;

      div {
        margin-left: 15px;
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        p {
          font-size: 14px;
          color: #000;
        }
        p + p {
          font-size: 12px;
          color: #999;
        }
      }
    }
    .no {
      font-size: 16px;
      color: #666;
    }
    .img {
      width: 40px;
      height: 40px;
      margin-left: 25px;
      border-radius: 50%;
      position: relative;
      .top1 {
        position: absolute;
        width: 23px;
        height: 22px;
        top: -12px;
        right: -10px;
      }
      .badge {
        width: 60px;
        height: auto;
        position: absolute;
        bottom: 0;
        left: 50%;
        margin-left: -30px;
        margin-bottom: -7px;
        font-size: 10px;
        text-align: center;
      }
    }

    .right {
      margin-right: 21px;
      span {
        font-size: 20px;
        color: #eb4d44;
      }
      span + span {
        margin-left: 3px;
        font-size: 14px;
      }
    }
  }
.btn {
  margin-top: 20px;
  width: 80px;
  height: 26px;
  background: #fff;
  color: #eb4d44;
  font-size: 14px;
  /*display: flex;*/
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  text-align: center;
  line-height: 26px;
}
.empty-text-wrap{
  margin-top: 150px;
  width: 100%;

}
</style>